#include "TabelaHash.h"

TabelaHash::TabelaHash()
{
    tabelaHash.resize(10);
}

void TabelaHash::insereSimbolo(QString simbolo) {
    tabelaHash[calculaHash(simbolo)].push_back(simbolo);
}

void TabelaHash::imprimirTabela() {
    for (int i = 0; i<m; i++){
        QString linha;
        for (int j = 0; j< tabelaHash[i].size(); j++){
            linha += tabelaHash[i][j] + ",";
        }
        qDebug() << linha;
    }
}

int TabelaHash::calculaHash(QString simbolo) {
    int hash = 0;
    for ( int i = 0; i < simbolo.length(); i++ )
        hash += 3 * (int)simbolo.at(i).toAscii();
    return hash%10;
}
